Skip to content

fix(config): keep page extensions out of module resolution#2594

Merged
james-elicx merged 2 commits into
cloudflare:mainfrom
lyzno1:fix/page-extension-route-collision
Jul 14, 2026
Merged

fix(config): keep page extensions out of module resolution#2594
james-elicx merged 2 commits into
cloudflare:mainfrom
lyzno1:fix/page-extension-route-collision

Conversation

@lyzno1

@lyzno1 lyzno1 commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Summary

  • keep pageExtensions scoped to route discovery instead of merging it into Vite's global resolve.extensions
  • preserve vinext's existing default extension priority, which matches Next.js 16 Turbopack for overlapping JavaScript and TypeScript extensions
  • preserve explicit turbopack.resolveExtensions, webpack resolve.extensions, and vinext's .cjs/.cts config resolution behavior
  • add a real App Router dev-server regression fixture covering HTML and RSC requests that collide with a root project file, an MDX route-discovery guard, and an extensionless .tsx/.js priority check

Root cause

vinext merged pageExtensions into Vite's module resolver. With md configured, an extensionless request such as /agents could resolve to a root agents.md file before the App Router handled the route. Depending on the Markdown contents, the request either returned transformed module content or failed during import analysis.

Next.js keeps page-file discovery separate from module import resolution. Custom module extensions remain supported through turbopack.resolveExtensions or webpack resolve.extensions.

The default resolver list is now independent from pageExtensions while preserving vinext's existing .tsx, .ts, .jsx, .js, .mjs priority. This avoids an unrelated compatibility change and follows the default ordering used by Next.js 16 Turbopack for the overlapping extensions.

Validation

  • vp test run tests/app-router-route-file-collision.test.ts tests/page-extensions-resolve.test.ts tests/init-cjs-config-resolve.test.ts tests/page-extensions-routing.test.ts
  • vp test run tests/file-matcher.test.ts tests/next-config.test.ts tests/shims.test.ts -t 'pageExtensions|resolve extensions|resolveExtensions'
  • vp check packages/vinext/src/index.ts packages/vinext/src/routing/file-matcher.ts tests/page-extensions-resolve.test.ts tests/app-router-route-file-collision.test.ts tests/fixtures/app-route-file-collision/next.config.mjs tests/fixtures/app-route-file-collision/app/agents/page.tsx tests/fixtures/app-route-file-collision/app/layout.tsx
  • git diff --check

Scope

This removes collisions introduced by custom pageExtensions. It does not change Vite's built-in extensionless resolution for its default JavaScript and TypeScript extensions.

@pkg-pr-new

pkg-pr-new Bot commented Jul 11, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@vinext/cloudflare@2594
npm i https://pkg.pr.new/create-vinext-app@2594
npm i https://pkg.pr.new/vinext@2594

commit: a1cc5b6

@lyzno1
lyzno1 marked this pull request as ready for review July 11, 2026 13:51
@github-actions

github-actions Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Performance benchmarks

Compared a1cc5b6 against base 8d0a18d using alternating same-runner rounds. Next.js was unchanged and skipped.

0 improved · 0 regressed · 6 within ±1.5%

Scenario Framework Baseline Current Change
Client bundle size (gzip) vinext 126.6 KB 126.6 KB ⚫ +0.0%
Client entry size (gzip) vinext 120.6 KB 120.6 KB ⚫ +0.0%
Dev server cold start vinext 2.73 s 2.74 s ⚫ +0.4%
Production build time vinext 2.94 s 2.91 s ⚫ -1.3%
RSC entry closure size (gzip) vinext 98.6 KB 98.6 KB ⚫ 0.0%
Server bundle size (gzip) vinext 165.3 KB 165.3 KB ⚫ -0.0%

View detailed results and traces

🟢 improvement · 🔴 regression · ⚫ change below 1.5% · paired base/head

@james-elicx
james-elicx merged commit 388144d into cloudflare:main Jul 14, 2026
53 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants